home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 79 / maccd 79.iso / multimedial / GL Tron / Source / gltron / data.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-10  |  5.8 KB  |  308 lines  |  [TEXT/CWIE]

  1. #ifndef DATA_H
  2. #define DATA_H
  3.  
  4. #include "gltron.h"
  5.  
  6. /* data structures */
  7.  
  8. typedef struct list list;
  9. struct list {
  10.   void *data;
  11.   list* next;
  12. };
  13.  
  14. typedef struct Grid {
  15.   int width, height;
  16.   unsigned char *data;
  17. } Grid;
  18.  
  19. typedef struct RuleSet {
  20.   int eraseCrashed;
  21.   float speed;
  22. } RuleSet;
  23.  
  24. typedef struct Time {
  25.   int current;
  26.   int lastFrame;
  27.   int offset; /* from SystemGetElapsedTime() */
  28.   int dt; /* current - lastFrame */
  29.  
  30.   /* float timeScale; */
  31. } Time;
  32.  
  33. enum {
  34.   EVENT_TURN_LEFT = 1,
  35.   EVENT_TURN_RIGHT = 2,
  36.   EVENT_CRASH = 4,
  37.   EVENT_STOP = 8
  38. };
  39.  
  40. enum {
  41.   TURN_LEFT = 3,
  42.   TURN_RIGHT = 1
  43. };
  44.  
  45. typedef struct GameEvent {
  46.   int type; /* what */
  47.   int player; /* who */
  48.   int x; /* where */
  49.   int y;
  50.   int timestamp;
  51. } GameEvent;
  52.   
  53. enum {
  54.   GAME_SINGLE = 1,
  55.   GAME_SINGLE_RECORD = 2,
  56.   GAME_PLAY = 4,
  57.   GAME_PLAY_NETWORK = 8,
  58.   GAME_NETWORK_RECORD
  59. };
  60.  
  61. enum {
  62.   NET_EVENT = 'e'
  63. };
  64.  
  65. typedef struct NetData {
  66.   char type[2];
  67.   char *data;
  68.   int length;
  69. } NetData;
  70.  
  71. typedef struct Network {
  72.   list *data;
  73. } Network;
  74.  
  75. typedef struct Game2 {
  76.   Grid grid;
  77.   RuleSet rules;
  78.   int mode;
  79.   int players;
  80.   int *startPositions;
  81.   Time time;
  82.   list events;
  83.   FILE *record;
  84.   FILE *play;
  85.   Network *network;
  86. } Game2;
  87.   
  88. typedef struct line {
  89.   int sx, sy, ex, ey;
  90. } line;
  91.  
  92. typedef struct fontbmp {
  93.   int texwidth; /* texture width */
  94.   int width; /* character width */
  95.  
  96.   int lower; /* lowest ascii character (normally: 32) */
  97.   int upper; /* highest ascii character (normally: 126) */
  98.  
  99.   texture *tex;
  100. } fontbmp;
  101.  
  102. typedef struct fonttex {
  103.   // sgi_texture **textures;
  104.   int nTextures;
  105.   
  106.   int texwidth; /* texture width */
  107.   int width; /* character width */
  108.  
  109.   int lower; /* lowest ascii character (normally: 32) */
  110.   int upper; /* highest ascii character (normally: 126) */
  111.  
  112.   unsigned int *texID;
  113.  
  114.   char *fontname;
  115.   char *bitmapname;
  116.   int bitmapTexwidth;
  117.   int bitmapWidth; /* character width */
  118. } fonttex;
  119.  
  120. typedef struct Model {
  121.   Mesh **mesh; /* models (lod) */
  122.   int lod; /* number of models */
  123.   // int *lod_dist;
  124.   
  125.   float color_alpha[4]; /* alpha trail */
  126.   float color_trail[4]; /* solid edges of trail */
  127.   float color_model[4]; /* model color */
  128. } Model;
  129.  
  130. typedef struct Data {
  131.   int iposx, iposy;
  132.   float posx, posy;
  133.   float t;
  134.   
  135.   int dir; int last_dir;
  136.  
  137.   int turn;
  138.   int turn_time; /* for cycle animation */
  139.   
  140.   int score;
  141.   float speed; /* set to -1 when dead */
  142.   float trail_height; /* countdown to zero when dead */
  143.   float exp_radius; /* explosion of the cycle model */
  144.   line *trails;
  145.   line *trail; /* current trail */
  146. } Data;
  147.  
  148. typedef struct Camera {
  149.   float cam[3];
  150.   float target[3];
  151.   float angle;
  152.   int camType;
  153. } Camera;
  154.  
  155. typedef struct AI {
  156.   int active;
  157.   int tdiff; /*  */
  158.   int moves;
  159.   long lasttime;
  160.   int danger;
  161.   int lastx, lasty;
  162. } AI;
  163.  
  164. typedef struct {
  165.   char *path;
  166.   char *name;
  167. } Artpack;
  168.  
  169. typedef struct gDisplay {
  170.   int win_id;     /* nur das globale Window hat eine */
  171.   int h, w;       /* window */
  172.   int vp_x, vp_y; /* viewport */
  173.   int vp_h, vp_w;
  174.   int blending;
  175.   int fog;
  176.   int shademodel;
  177.   int wall;
  178.   int onScreen;
  179.  
  180.   /* texture ID */
  181.   unsigned int *textures;
  182.  
  183.   /* software rendering stuff */
  184.   unsigned char *pixelGui;
  185.   fontbmp *bitfont;
  186.   Artpack artpack;
  187. } gDisplay;
  188.  
  189. typedef struct Player {
  190.   Model *model;
  191.   Data *data;
  192.   Camera *camera;
  193.   gDisplay *display;
  194.   AI *ai;
  195. } Player;
  196.  
  197. /* if you want to add something and make it permanent (via
  198.    .gltronrc) then
  199.    1) add it to Settings in data.h
  200.    2) add it to settings.txt
  201.    3) add pointer to initSettingData() in settings.c
  202.    4) add a default to initMainGameSettings() in settings.c
  203.    5) make a menu entry in menu.txt
  204. */
  205.  
  206. enum {
  207.   BILINEAR = 0,
  208.   TRILINEAR = 1
  209. };
  210.  
  211. typedef struct Settings {
  212.   /* these settings affect the visuals and sound etc.
  213.      and are client side only */
  214.  
  215.   int show_help;
  216.   int show_fps;
  217.   int show_wall;
  218.   int show_2d;
  219.   int show_alpha;
  220.   int alpha_trails;
  221.   int light_cycles;
  222.  
  223.   int show_skybox;
  224.   int show_floor_texture;
  225.   int show_glow;
  226.   int show_ai_status;
  227.   int show_model;
  228.   int lod;
  229.   int show_crash_texture;
  230.   int model_backwards;
  231.   int turn_cycle; /* smooth turning */
  232.   int line_spacing; /* space between lines when the floor texture is
  233.                disabled */
  234.  
  235.   int stretch_textures;
  236.   int use_mipmaps; /* enable / disable mipmapping */
  237.   int mipmap_filter; /* bilinear / trilinear */
  238.  
  239.   int softwareRendering;
  240.   int camType;
  241.   int mouse_warp;
  242.  
  243.   int display_type; /* 0-2 -> 1, 2 or 4 displays on the screen */
  244.   int content[4]; /* max. 4 individual viewports on the screen */
  245.   int windowMode; /* 0: fullscreen, non-zero: window mode */
  246.  
  247.   int fov; /* field ov view (vertical angle) */
  248.   float znear; /* the near z-Plane */
  249.   int width; /* screen width & height */
  250.   int height;
  251.  
  252.   int playMusic;
  253.   int playEffects;
  254.  
  255.   float musicVolume;
  256.   float fxVolume;
  257.  
  258.   list* soundList;
  259.   int soundIndex;
  260.   int soundSongCount;
  261.   /* these two are ignored in multiplayer mode */
  262.   int fast_finish;
  263.   int screenSaver; /* 1: all for players are AIs when the game starts */
  264.  
  265.   /* no AI in multiplayer yet */
  266.   int ai_player1;
  267.   int ai_player2;
  268.   int ai_player3;
  269.   int ai_player4;
  270.   int ai_level;
  271.  
  272.   /* these gettings affect the gameplay */
  273.   int erase_crashed;
  274.   int game_speed; /* index */
  275.   float current_speed;
  276.   int grid_size;
  277.   int arena_size; /* index */
  278. } Settings;
  279.  
  280. typedef struct Game {
  281.   gDisplay *screen;
  282.   Settings *settings;
  283.   Player *player;
  284.   int players; /* number of players - currently limited to 4 somewhere */
  285.   int winner; /* who won this round */
  286.   int pauseflag; /* if the game is finished: the PAUSE_GAME_FINISHED flag
  287.             is set */
  288.   int running; /* the amount of players that are still alive */
  289. } Game;
  290.  
  291. typedef struct settings_int {
  292.   char name[32];
  293.   int *value;
  294. } settings_int;
  295.  
  296. typedef struct settings_float {
  297.   char name[32];
  298.   float *value;
  299. } settings_float;
  300.  
  301.  
  302. typedef struct settings_v {
  303.   char name[32];
  304.   void (*value)(char*, FILE*);
  305. } settings_v;
  306.  
  307. #endif
  308.